package com.zzld.modules.maintenance.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.github.abel533.entity.Example;
import com.zzld.core.service.BaseServiceImpl;
import com.zzld.modules.common.dto.TreeGrid;
import com.zzld.modules.maintenance.entity.Path;
import com.zzld.modules.maintenance.mapper.PathMapper;
import com.zzld.modules.maintenance.service.IPathService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PathServiceImpl extends BaseServiceImpl<Path> implements IPathService {
    @Autowired
    private PathMapper pathMapper;

    private static final Logger logger = LoggerFactory.getLogger(PathServiceImpl.class);

	@Override
	public List<TreeGrid> treeGrid() {
		// TODO 自动生成的方法存根
		List<Path> list = new ArrayList<Path>();
		List<TreeGrid> treeGrids = new ArrayList<TreeGrid>();
		Example e = new Example(Path.class);
		list = pathMapper.selectByExample(e);
		for(Path p :list){
			TreeGrid treegrid = new TreeGrid();
			BeanUtils.copyProperties(p, treegrid);
			treegrid.setText(p.getPathname());
			treegrid.setId(p.getId());
			treegrid.setPid(p.getPid());
			treegrid.setCreateDate(p.getCreateTime());
			treeGrids.add(treegrid);
		}
		return treeGrids;
	}
}